package cn.com.czpb.client.module.video.activity;

import android.app.Activity;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.ViewGroup;

import cn.com.czpb.client.R;
import cn.com.czpb.client.module.video.utils.VideoPlayState;
import cn.com.czpb.client.module.video.utils.VideoPlayerHelper;
import cn.com.czpb.client.module.video.view.VideoPlayerView;


/**
 * qiu
 */
public class FullScreenPlayVideoActivity extends Activity
            implements VideoPlayerView.ExitFullScreenListener {

    private VideoPlayState mCurrPlayState;
    private ViewGroup mParent;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_fullscreen_play_video);
        mParent = findViewById(R.id.root);
        VideoPlayerHelper.getInstance().fullScreen(mParent, FullScreenPlayVideoActivity.this);
    }

    @Override
    protected void onPause() {

        super.onPause();
        mCurrPlayState = VideoPlayerHelper.getInstance().getVideoPlayState();
        VideoPlayerHelper.getInstance().pause();
    }

    @Override
    protected void onResume() {

        super.onResume();
        if(mCurrPlayState == VideoPlayState.PLAY) {
            VideoPlayerHelper.getInstance().play();
        }
    }

    @Override
    protected void onStop() {

        VideoPlayerHelper.getInstance().exitFullScreen(mCurrPlayState);
        super.onStop();
    }

    @Override
    public void exitFullScreen() {

        finish();
    }
}
